#include "app_buffer.h"

int main(int argc, char *argv[])
{
    Buffer *buffer = app_BufferInit(1024);

    char data[128];
    for (int i = 0; i < 128; i++)
    {
        data[i] = 'a';
    }
    app_BufferWrite(buffer, data, 128);
    for (int i = 0; i < 128; i++)
    {
        data[i] = 'b';
    }
    app_BufferWrite(buffer, data, 128);
    // app_BufferWrite(buffer,"Hello world", 12);
    // app_BufferWrite(buffer,"Hello", 6);
    char read_buf1[256] = {0};
    int buf1_len = app_BufferRead(buffer, read_buf1, 256);
    log_info("第一次读取数据 %.*s,长度为：%d", buf1_len, read_buf1, buf1_len);
    // app_BufferWrite(buffer, data, 128);
    char read_buf2[256]= {0};
    int buf2_len = app_BufferRead(buffer, read_buf2, 256);
    log_info("第二次读取数据 %.*s,长度为：%d", buf2_len, read_buf2, buf2_len);
    char read_bufe[256]= {0};
    int bufe_len = app_BufferRead(buffer, read_bufe, 256);
    log_info("第3次读取数据 %.*s,长度为：%d", bufe_len, read_bufe, bufe_len);
    app_BufferDestroy(buffer);
    return 0;
}